﻿using Report_IDal.TiJian;
using Report_Model.TiJian;
using Report_Unity.Basic;
using Report_Unity.Unitys;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Report_Dal.TiJian
{
    public class TJ_ZDZHXMDal : ITJ_ZDZHXMDalDal
    {
        private SqlHelper sqlHelper = null;

        public TJ_ZDZHXMDal(string conn)
        {
            sqlHelper = new SqlHelper(conn);
        }

        public List<TJ_ZuHeXM> GetZuHeXM(string hid)
        {
            string sql = $@"SELECT [单位ID] AS dwid,[类别编码] AS lbbm,[类别名称] AS lbmc,
[科室编码] AS ksbm,[科室名称] AS ksmc,[组合编码] AS zhxmbm,[组合名称] AS zhxmmc,
ISNULL([项目单价], 0) AS xmdj,[性别限制] AS xb
FROM TJ_ZDZHXM AS zhxm WHERE zhxm.[单位ID]='{hid}'"; // AND zhxm.[删除标志]=1

            List<TJ_ZuHeXM> list = sqlHelper.GetData<TJ_ZuHeXM>(sql, System.Data.CommandType.Text);

            return list;
        }

        public string GetXMMC(string hid,string itemid)
        {
            string sql = $@"SELECT [组合名称] AS zhxmmc
FROM TJ_ZDZHXM AS zhxm WHERE zhxm.[单位ID]='{hid}' AND zhxm.[组合编码]='{itemid}'";

            string result = string.Empty;
            DataTable dt = sqlHelper.GetData(sql,System.Data.CommandType.Text);
            if (dt != null && dt.Rows.Count > 0)
                result = dt.Rows[0][0].ToString();

            return result;
        }
    }
}
